<template>
  <div class="replyGrade">
     <el-form ref="form" label-width="120px">
       <div class="formLeft">
          <el-form-item label="学院：">
            <div>{{formOne.college}}</div>
          </el-form-item>
          <el-form-item label="班级：">
            <div>{{formOne.empClass}}</div>
          </el-form-item>
          <el-form-item label="学生学号：">
            <div>{{formOne.stuNum}}</div>
          </el-form-item>
          <el-form-item label="学生姓名：">
            <div>{{formOne.stuName}}</div>
          </el-form-item>
          <el-form-item label="毕设题目：">
            <div>{{formOne.topicTitle}}</div>
          </el-form-item>
          <el-form-item label="指导老师：">
            <div>{{formOne.jsName}}</div>
          </el-form-item>
          <el-form-item label="分组组名：">
            <div>{{formOne.groupName}}</div>
          </el-form-item>
       </div>
       <div class="formRight">
          <el-form-item label="答辩地点：">
            <div>{{formOne.groupAddress}}</div>
          </el-form-item>
          <el-form-item label="答辩成绩：">
            <div>{{formOne.groupGrade}}</div>
          </el-form-item>
          <el-form-item label="答辩申请：">
            <span>{{formOne.applyStep}}</span>
            <el-button type="primary" :loading="showLoad" @click="applyClick">申请答辩</el-button>
          </el-form-item>
          <el-form-item label="答辩申请结果：">
            <div>{{formOne.applyPass}}</div>
          </el-form-item>
       </div>
      </el-form>
  </div>
</template>

<script>
import { axiosRequest } from "@/utils/axiosRequest";
export default {
  data() {
    var userInfo = JSON.parse(window.sessionStorage.getItem('userInfo')).user;
    return {
      listNum: userInfo.loginCode, //当前登录的信息
      formOne: {},
      showLoad: false,
    }
  },

  methods: {
    // 答辩申请按钮
    applyClick() {
      var self = this;
      if(self.formOne.applyStep == "已申请") {
        self.$alert('您已经提交了申请，请勿重复提交！！！', '提示', {
          confirmButtonText: '确定',
          callback: () => {
            self.$message({
              type: 'info',
              message: `确定信息！！！ `
            });
          }
        });
        return;
      }else {
        self.showLoad = true;
        self.formOne.applyStep = "已申请";
      }
      var newForm = self.formOne;
      axiosRequest("post","/groupInfo/save",newForm).then((res) => {
          if (res.data.code === 200) {
              setTimeout(() => {
                this.showLoad = false;
                self.gettableList();
                self.$message({
                  message: '申请答辩成功！！！',
                  type: 'success'
                });
              }, 2000);
            } else {
              self.$message({
                showClose: true,
                message: '申请答辩，请求信息失败了！！！',
                type: 'error'
              });
            }
        });
    },

    // 请求后台题目数据
    gettableList(){
      var self = this;
      axiosRequest("get","/groupInfo/listAll",null).then((res) => {
          if (res.data.code === 200) {
              self.formOne = res.data.data.find( function(e) {
                return e.stuNum == self.listNum;
              })
          } else {
              self.$message({
                showClose: true,
                message: '错了哦，请求信息失败了！！！',
                type: 'error'
              });
            }
        });
    },   

  },

  mounted: function() {
    var self = this;
    self.gettableList();
  },
}
</script>

<style lang="less" scoped>
.replyGrade {
  padding-left: 10px;
  position: relative;
}

.el-form {
  display: flex;
  justify-content: space-between;
}

.formLeft,.formRight {
  width: 50%;
}

.el-button {
  margin-left: 10%;
  padding: 8px 11px;
}

</style>
